﻿//////////////////////////////////////////////////////////////////////////////////////
///// resultScreen.cs                                                 /////
///// 미니게임의 결과 화면                                       /////
//////////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;

namespace Pyramid_Game
{
    public class resultScreen : GameScreen
    {
        #region Declarations

        public enum MiniGame
        {
            CatchMummy,
            FindOfRoom,
            FlyBat,
            MakePolygon
        }
        private MiniGame miniGame = MiniGame.CatchMummy;

        int count, maxCount;
        double clearTime;

        Vector2 resultPosition = Vector2.Zero;

        Texture2D resultTexture;
        GameScreen resultObject;
        #endregion

        #region Load

        //CatchMummy result
        public resultScreen(int count, int maxCount)
        {
            this.count = count;
            this.maxCount = maxCount;
            miniGame = MiniGame.CatchMummy;
            resultObject = new Script(count.ToString() + " / " + maxCount.ToString(), 50, resultPosition);
        }
        //FindOfRoom, MakePolygon result
        public resultScreen(double clearTime, string name)
        {
            this.clearTime = clearTime;

            switch(name)
            {
                case "FindOfRoom":
                    miniGame = MiniGame.FindOfRoom;
                    break;
                case "MakePolygon":
                    miniGame = MiniGame.MakePolygon;
                    break;
            }
            resultObject = new Script(clearTime.ToString("F2"), 50, resultPosition);
        }

        public override void LoadContent(ContentManager content)
        {
            resultTexture = content.Load<Texture2D>("Texture/blank");
            switch (miniGame)
            {
                case MiniGame.CatchMummy:
                    screenManager.AddScreen(resultObject);
                    break;
                case MiniGame.FindOfRoom:
                    screenManager.AddScreen(resultObject);
                    break;
                case MiniGame.FlyBat:
                    break;
                case MiniGame.MakePolygon:
                    break;
            }
        }

        #endregion

        #region Update & Draw

        public override void Update(Touch touch, GameTime gameTime)
        {
            foreach (GestureSample gesture in touch.Gestures)
            {
                if (gesture.GestureType == GestureType.Tap)
                {
                    Point tapLocation = new Point((int)gesture.Position.X, (int)gesture.Position.Y);

                    Map.playerPoint = Map.floors[Map.playerPoint].NextIndex;
                    screenManager.RemoveScreen(this);
                    screenManager.AddScreen(new Background());
                }
            }
        }
        public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            spriteBatch.Draw(resultTexture, Vector2.Zero, Color.White);
        }

        #endregion
    }
}